package com.example.matrixdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private Button btClick;
    private Button btTwo;
    private TextView tvMenu;
    private MatrixLayout ml;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btClick = (Button) findViewById(R.id.bt_click);
        btTwo = (Button) findViewById(R.id.bt_two);
        tvMenu = (TextView) findViewById(R.id.tv_menu);
        ml = (MatrixLayout) findViewById(R.id.ml);
        tvMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ml.toggle();
            }
        });
        //设置状态改变的监听
        ml.setOnStatusChangeListener(new MatrixLayout.OnStatusChangeListener() {
            @Override
            public void onExpansion() {
                tvMenu.setText("收起");
            }

            @Override
            public void onPutaway() {
                tvMenu.setText("展开");
            }
        });
        btTwo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "点击2", Toast.LENGTH_SHORT).show();
            }
        });
        btClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "点击", Toast.LENGTH_SHORT).show();
            }
        });
    }
}